package com.ssy.lingxi.platform.manage.entity.base;

import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.ssy.lingxi.platform.manage.model.request.shop.ShopRuleRequest;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.NotEmpty;
import java.util.List;

/**
 * 商城规则类
 *
 * @author wyx
 * @version 2.0.0
 * @date 2021-09-24
 */
@Getter
@Setter
@Entity
@Table(schema = "public", name = "man_shop_rule",
        indexes = {@Index(name = "man_shop_rule_member_id_member_role_id_idx", columnList = "memberId,memberRoleId")})
public class ShopRule {

    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "shop_rule_seq")
    @SequenceGenerator(sequenceName = "man_shop_rule_seq", name = "shop_rule_seq", allocationSize = 1)
    private Long id;

    /**
     * 会员id
     */
    @Column
    private Long memberId;

    /**
     * 会员名称
     */
    @Column
    private String memberName;

    /**
     * 会员类型名称
     */
    @Column
    private String memberTypeName;

    /**
     * 会员角色id
     */
    @Column
    private Long memberRoleId;

    /**
     * 会员角色名称
     */
    @Column
    private String roleName;

    /**
     * 会员等级
     */
    @Column
    private Integer level;

    /**
     * 会员等级标签
     */
    @Column
    private String levelTag;

    /**
     * 状态 0-无效 1-有效
     */
    @Column
    private Integer status;

    /**
     * 创建时间
     */
    @Column
    private Long createTime = System.currentTimeMillis();

    /**
     * 一对多双向关联商城
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "shopRule", cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE}, fetch = FetchType.LAZY)
    private List<ShopRuleDetail> shopList;
}
